package mainControls;

import java.util.ArrayList;

import smallTools.SimpleTime;
import entities.Section;
import entities.Staff;

public class StaffScheduleChecker {

	public boolean check(Section theSection, SimpleTime startTimeCandidate) {
		String staffId = theSection.getSectionStaffId();
		Staff targetStaff = Staff.getStaffById(staffId);
		int duration = theSection.getSectionDuration();

		ArrayList<String> relatedSectionIds = targetStaff.getAllSectionIds();
		for (String id : relatedSectionIds) {
			Section now = Section.getSectionById(id);
			SimpleTime stNow = now.getSectionStartTime();
			int durationNow = now.getSectionDuration();
			if (stNow != null) {
				if (SimpleTime.areSectionsConflicted(stNow, durationNow,
						startTimeCandidate, duration))
					return false;
			}
		}

		return true;
	}
}
